#ifndef TEXT_H
#define TEXT_H

#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include <exception>
#include <stdexcept>
#include <algorithm>
#include <memory>

#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/sax2/DefaultHandler.hpp>
#include <xercesc/sax2/Attributes.hpp>
#include <xercesc/sax2/XMLReaderFactory.hpp>

using namespace xercesc;

class Text
{
public:
	virtual size_t readText(std::string const & file_name) = 0;

private:
	
protected:
	static bool isLetter(char a);
	static size_t wordCount(std::string const & text);	
	Text();
};

class TxtText : public Text
{
public:
	TxtText();
	size_t readText(std::string const & file_name);
	
private:

};

class XmlText:  public DefaultHandler, public Text
{
public:
	XmlText();
	~XmlText();
	size_t readText(std::string const & file_name);
	void startElement(const XMLCh* const uri, const XMLCh* const localname, const XMLCh* const qname, const   Attributes&     attrs );
	void endElement  (const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname);
	void characters  (const XMLCh *const chars, const XMLSize_t length);
	void endDocument ();
	
private:
	XmlText(const XmlText &);
	XmlText & operator = (const XmlText &);
	void XMLStrToStr(char * line, std::string & str);
private:
	std::string buffer;
	size_t word_num;
};
#endif